/**
 * 
 */
package hb_Teach_InitObject_Date;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import org.junit.Test;

/**
 * @author Jiang Zhiyan
 *
 * 2021年5月20日 上午10:50:34
 */
public class localDate {
    @Test
   public void localDateTest() {
//     1、localDate表示日期
	LocalDate now = LocalDate.now();
    System.out.println(now); //2021-05-20
    LocalDate day1 = now.plusDays(1);
    System.out.println(day1);//2021-05-21
    LocalDate minusDays = now.minusDays(1);
    System.out.println(minusDays);//2021-05-19
    
    System.out.println("初始值now："+now); //计算后的now不变
    
    int month = now.getMonthValue(); 
    System.out.println(month);
    
    LocalDate p1= LocalDate.parse("2021-05-20");  
    System.out.println(p1);
    
//    指定日期格式
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy'年'MM'月'dd'日'");
    LocalDate p2 = LocalDate.parse("2022年05月20日",dtf);
    System.out.println(p2);
    String str = p2.format(dtf);
    System.out.println(str);
   }
}
